/**
 * @param {number[]} postorder
 * @return {boolean}
 */
var verifyPostorder = function(postorder) {
    if(postorder.length===0) return true
    let left = []
    let right =[]
    let rootVal = postorder[postorder.length-1]
    let index = 0
    for(;index<postorder.length;index++){
        if(postorder[index]<rootVal){
            left.push(postorder[index])
        }else{
            break
        }
    }
    for ( ; index<postorder.length; index++){
        if(postorder[index]<rootVal)return false
        right.push(postorder[index])
       
    }
    return verifyPostorder(left)&&verifyPostorder(right)
 
 };

 const s =verifyPostorder([4, 8, 6, 12, 16, 14, 10])
 console.log(s)